//将时间格式化（yyyy-mm-dd hh:mm:ss）
function getFormatDateDateTime(date, time) {
    var formatDate = new Date(date);
    var formatTime = new Date(time);
    var month = formatDate.getMonth() + 1;
    var date = formatDate.getDate();
    var hour = formatTime.getHours();
    var min = formatTime.getMinutes();
    if (date < 10)
        date = '0' + date;
    if (month < 10)
        month = '0' + month;
    if (hour < 10)
        hour = '0' + hour;
    if (min < 10)
        min = '0' + min;
    return formatDate.getFullYear() + '-' + month + '-' + date + ' ' + hour + ':' + min + ':00';
}

//将时间格式化（yyyy-mm-dd）
function getFormatDate(date) {
    var formatDate = new Date(date);
    var month = formatDate.getMonth() + 1;
    var date = formatDate.getDate();
    if (date < 10)
        date = '0' + date;
    if (month < 10)
        month = '0' + month;
    return formatDate.getFullYear() + '-' + month + '-' + date;
}

//将时间格式化（hh:mm:ss）
function getFormatTime(time) {
    var formatTime = new Date(time);
    var hour = formatTime.getHours();
    var min = formatTime.getMinutes();
    if (hour < 10)
        hour = '0' + hour;
    if (min < 10)
        min = '0' + min;
    return hour + ':' + min + ':00';
}

//计算目前的时间跟目标时间的差距是否大于几分钟
function checkTimeIsFarWay(targetTime, space) {
    console.log('执行CheckTIme');
    var nowDate = new Date(); //当前时间
    var targetDate = new Date(targetTime);
    var spaceMm = space * 60 * 1000;//将间隔时间转换为毫秒
    var spaceTime = targetDate.getTime() - nowDate.getTime(); //时间差的毫秒数
    return spaceTime > spaceMm;
}

//检验两个时间是不是前者早于后者
function checkTimeIsOrder(beginTime, endTime) {
    var begin = new Date(beginTime);
    var end = new Date(endTime);
    var spaceTime = end.getTime() - begin.getTime(); //时间差的毫秒数
    return spaceTime > 0;
}

//检验两个时间是不是相等
function checkTimeIsSame(oneTime, otherTime) {
    var one = new Date(oneTime);
    var other = new Date(otherTime);
    var spaceTime = one.getTime() - other.getTime(); //时间差的毫秒数
    return spaceTime == 0;
}